#import "HiLo.h"
#import <stdio.h>
#import <appkit/Form.h>

float getrand()
{
	return((float) rand()/(float) MAXRND);
}

@implementation HiLo

+ new
{
	self = [super new];
	numberOfGuesses = 0;
	number = (int) (100.0*getrand());
	printf("%d\n", number);
	return self;
}

- setHint:anObject
{
    hint = anObject;
    return self;
}

- setNumberGuesses:anObject
{
    numberGuesses = anObject;
    return self;
}

- newGame:sender
{
	number = (int) (100.0*getrand());
	numberOfGuesses = 0;
	[numberGuesses setIntValue:0];
	printf("%d\n", number);
	return self;
}

- guess:sender
{
	answer = [sender intValue];
	if (answer > number) {
		[hint setStringValue:"Too High"];
		numberOfGuesses++;
		[numberGuesses setIntValue:numberOfGuesses];
		[sender selectTextAt:0];
	}
	else if (answer < number) {
    	[hint setStringValue:"Too Low"];
		numberOfGuesses++;
		[numberGuesses setIntValue:numberOfGuesses];
		[sender selectTextAt:0];
	}
	else if (answer == number) {
	 	[hint setStringValue:"That is Correct!"];
	}
	return self;
}


@end
